<?php
	class ShopTypeAttrController extends CommonController{

		public $model;

		public function __init(){

			parent:: __init();

			$this->model = K('Shop_type_attr');

		}

		public function index(){
			//获得get参数传过来的tid
			$tid= Q('get.tid',0,'intval');
			
			$typeAttr = $this->model->where("shop_type_tid={$tid}")->all();
			// p($typeAttr);die;
			$this->assign('typeAttr',$typeAttr);

			$this->display();
		}

		public function add(){

			$tid= Q('get.tid',0,'intval');

			if (IS_POST) {
				if (!$this->model->add_data($tid)) {
					$this->error($this->model->error);
				}
				$this->success('添加属性成功');
			}

			$this->display();

		}

		//修改类型属性值
		public function edit(){

			$taid= Q('get.taid',0,'intval');
			//调老数据
			$data = $this->model->where("taid={$taid}")->find();
			// p($data);die;

			$this->assign('data',$data);
			//提交修改的内容
			if (IS_POST) {
				if (!$this->model->edit_data($taid)) {
					
					$htis->error($this->model->error);
				}

				$this->success('类型属性修改成功');
			}

			$this->display();
		}

		public function del(){

			$taid= Q('get.taid',0,'intval');

			$this->model->del($taid);

			$this->success('删除成功');
		}
	}











?>